package main

import (
	"MyBlogv2/common/models"
	"MyBlogv2/common/redisUtil"
	"fmt"
	"log"
)

func main() {
	var allArticleContent []string
	models.Db.Model(new(models.Article)).Select("article_content").Find(&allArticleContent)
	
	wordCount := 0
	for i := 0; i < len(allArticleContent); i++ {
		wordCount += len(allArticleContent[i])
	}
	
	err := redisUtil.SetWebsiteWordCount(wordCount)
	if err != nil {
		log.Fatalf("Failed to set word count: %v", err)
	}
	
	fmt.Printf("Successfully initialized website word count: %d\n", wordCount)
}
